package user_assets_pix

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserPixWalletUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 用户Pix钱包信息 - 查询
func NewUserPixWalletUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserPixWalletUpdateLogic {
	return &UserPixWalletUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserPixWalletUpdateLogic) UserPixWalletUpdate(req *types.UserPixWalletUpdateRequest) (resp *types.UserPixWalletUpdateResponse, err error) {
	_, err = l.svcCtx.AssetsRpc.UserChannel.UserPixWalletsUpdate(l.ctx, &rpc.UserPixWalletsUpdateRequest{
		Id:         req.ID,
		UserId:     req.UserID,
		WalletType: req.WalletType,
		Username:   req.Username,
		Account:    req.Account,
		Cpf:        req.CPF,
	})
	if err != nil {
		return &types.UserPixWalletUpdateResponse{
			IsUpdate: false,
		}, nil
	}
	return &types.UserPixWalletUpdateResponse{
		IsUpdate: true,
	}, nil
}
